﻿@model IEnumerable<AuditModel.Archive>
@{
    AuditWeb.Models.AdminArchiveModel aam = ViewBag.AAM;
    bool checkbox=true;
    if(ViewBag.CheckBox!=null)
    {
        checkbox = (bool)ViewBag.CheckBox;
    }
    bool report = false;
    if(ViewBag.Report!=null)
    {
        report = (bool)ViewBag.Report;
    }
}
<table>
    <tr>
        @if ((User.IsInRole("区县管理员") || User.IsInRole("管理员")) && checkbox)
        {<th>
        </th>}
        <th>
            @AuditResources.Archive.ID
        </th>
         @if (!User.IsInRole("区县管理员"))
         {
        <th>
             @AuditResources.Archive.CountyCode
        </th>
         }
         @if (!User.IsInRole("学科组组长") && !User.IsInRole("评委"))
         {
        <th>
             @AuditResources.Archive.SubjectID
        </th>
         }
        <th>
             @AuditResources.Archive.TeacherName
        </th>
        <th>
             @AuditResources.Archive.ClassTitle
        </th>
        <th>
             @AuditResources.Archive.SchoolName
        </th>
       <th>
             @AuditResources.Archive.ClassDate
        </th>
        <th>
             @AuditResources.Archive.ClassTime
        </th>
         @if (User.IsInRole("评委") || User.IsInRole("管理员") || User.IsInRole("学科组组长"))
         {
        <th>
             @AuditResources.Archive.EvaluationStartDate
        </th>
        <th>
             @AuditResources.Archive.EvaluationDueDate
        </th>
         }
        @if ((User.IsInRole("区县管理员") || User.IsInRole("评委") || User.IsInRole("管理员") || User.IsInRole("学科组组长"))&& checkbox&&!report)
        {
        <th></th>
        }
        <th></th>
        
    </tr>

@foreach (var item in Model)
{
    <tr>
       @if ((User.IsInRole("区县管理员") || User.IsInRole("管理员")) && checkbox)
       {<td>
       
       @Html.CheckBox(item.ID)
           
       </td>
       }
        <td>
            @Html.DisplayFor(modelItem => item.ID)
        </td>
        @if (!User.IsInRole("区县管理员"))
        {
        <td>
            @Html.DisplayFor(modelItem => item.County.Name)
        </td>
        }
        @if (!User.IsInRole("学科组组长") && !User.IsInRole("评委"))
        {
        <td>
            @Html.DisplayFor(modelItem => item.Subject.Name)
        </td>
        }
        <td>
            @Html.DisplayFor(modelItem => item.TeacherName)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.ClassTitle)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.SchoolName)
        </td>
        <td>
            @{string date = item.ClassDate != null ? item.ClassDate.Value.ToShortDateString() : "";}
            @date
        </td>
        <td>
            @{string time = item.ClassTime != null ? item.ClassTime.Value.ToShortTimeString() : "";
}
@time
        </td>
        @if (User.IsInRole("评委") || User.IsInRole("管理员") || User.IsInRole("学科组组长"))
        {
        <td>
            @{string startdate = item.EvaluationStartDate != null ? item.EvaluationStartDate.Value.ToShortDateString() : "";
}
@startdate
        </td>
        <td>
        @{string duedate = item.EvaluationDueDate != null ? item.EvaluationDueDate.Value.ToShortDateString() : "";
}
@duedate</td>
        }
        @if (checkbox&&!report)
        {
            if (User.IsInRole("区县管理员"))
            {<td style="width:140px;">
                @Html.ActionLink(AuditResources.UI.Edit, "Edit", new { id = item.ID }, new { @class = "button" }) <text>|</text>
                @Html.ActionLink(AuditResources.UI.Details, "Details", new { id = item.ID }, new { @class = "button" }) <text>|</text>
                @Html.ActionLink(AuditResources.UI.Delete, "Delete", new { id = item.ID, error = false }, new { @class = "button" })
            </td>}
            else if (User.IsInRole("评委"))
            {
                <td style="width:90px;">
              @Html.ActionLink(AuditResources.UI.Details, "ArchiveDetails","PW", new { id = item.ID }, new { @class = "button" }) 
              @if (DateTime.Now >= item.EvaluationStartDate && DateTime.Now <= item.EvaluationDueDate.Value.AddDays(1))
              {
                  <text>|</text> @Html.ActionLink(AuditResources.UI.ScoreAction, "Score", "PW", new { id = item.ID, returnaction = "Archives" }, new { @class = "button" }) 
              }
                </td>
            }
            else if (User.IsInRole("管理员"))
            {
                <td style="width:40px;">
                @Html.ActionLink(AuditResources.UI.Delete, "DeleteArchive", "Admin", new { id = aam.AnnualEventId, countycode = aam.CountyCode, subjectid = aam.SubjctId, archiveid = aam.ArchiveId, targetarchiveid = item.ID }, new { @class = "button", @onclick = "return confirm('要删除吗？');" }) 
                </td>
            }
            else if (User.IsInRole("学科组组长"))
            {
                <td style="width:40px;">
                @Html.ActionLink(AuditResources.UI.Details, "ArchiveDetails","SubjectAdmin", new { id = item.ID }, new { @class = "button" }) 
                </td>
            }
        }
        <td style="width:80px;">
              @Html.ActionLink("下载附件", "GetCompressedFilesByArchiveId", "DownloadManager", new { id = item.ID }, new { @class = "button" }) 
                </td>
    </tr>
}

</table>